package GlavFinans::Module::Customer;

use Modern::Perl;

use Data::Dumper;
use Mojo::Base 'Mojolicious';
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::Loader;

has 'app';
has config => sub {{}};
has name => 'customer';

sub register {
	my ($self, $app, $conf) = @_;
	
	$app->routes->namespace('GlavFinans::Module::Core::Controller');
    
	my $r = $app->routes->bridge->to( controller => 'Auth', action => 'checkSession', layout => 'customer');
	my $a = $r->bridge->to( controller => 'Auth', action => 'checkAuth');
	
	my $route = {
		'anon' => {
			'bridge'    => $r,
			'layout'    => 'frontend',
			'namespace' => 'GlavFinans::Module::Customer::Controller',
			'route'     => [
				['get',  '/customer/join', 'Join', 'index', 'customer_join_index'],
				['post', '/customer/join', 'Join', 'create', 'customer_join_create'],
				['get',  '/activate/:code', 'Customer', 'activate', 'customer_activate'],
			]
		},
		'auth' => {
			'bridge'    => $a,
			'layout'    => 'customer',
			'namespace' => 'GlavFinans::Module::Customer::Controller',
			'route'     => [
				['get', '/customer', 'Front', 'index', 'customer_front_index'],
			]
		}
	};
	
	$app->route($route);
}

1;